package com.taikang.hmp.hbusiness.doctor.register.action.view;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.taikang.hmp.frame.common.TKException;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.web.action.BaseAction;
import com.taikang.hmp.hbusiness.doctor.register.service.ActivationService;

public class ActivationViewAction  extends  BaseAction{
	protected final Log logger = LogFactory.getLog(getClass());

	private ActivationService activationService;
	
	public ActivationService getActivationService() {
		return activationService;
	}

	public void setActivationService(ActivationService activationService) {
		this.activationService = activationService;
	}

	@Override
	public String executeAction() {
		if ("getActivationList".equals(requestDto.getMethod())){
			logger.info("--获取激活码列表: getActivationList method --");
			return getActivationList();
		} else {
			throw new TKException("no support method:" + requestDto.getMethod());
		}
	}

	private String getActivationList() {
		ResponseDto responseDto = new ResponseDto();
		//获取参数
		Dto paramDto = null;
		if(requestDto.getRequestlist()!=null && !requestDto.getRequestlist().isEmpty()){
			paramDto = requestDto.getRequestlist().get(0);
		}
		paramDto = super.appendRequestBase(paramDto, requestDto);
		List<Dto> activationList = activationService.getActivationList(paramDto);
		Dto resultDto = new BaseDto();
		resultDto.put("resultlist", activationList);
		responseDto.pushResultDto(resultDto);
		super.setDataMap(responseDto);
		return SUCCESS;
	}
}
